#ifndef CAPTURER_H
#define CAPTURER_H

#include <QObject>

class SampleGrabberCallback
{
public:
	virtual void sample(const QImage& image) = 0;
};

class CapturerPrivate;
class Capturer : public QObject
{
	Q_OBJECT
	Q_PROPERTY(QRect viewport READ viewport WRITE setViewport)	
	Q_PROPERTY(QSize pixelRatio READ pixelRatio WRITE setPixelRatio)
	Q_PROPERTY(bool horizontalFlip READ horizontalFlip WRITE setHorizontalFlip)
	Q_PROPERTY(bool verticalFlip READ verticalFlip WRITE setVerticalFlip)
public:
	Capturer(const uint index, QObject *parent);
	~Capturer();
public:
	uint index() const;
	QPointF position() const;
	void setPosition(const QPointF& );	
	QRect viewport() const;
	void setViewport(const QRect& viewport);
	QSize pixelRatio() const;
	void setPixelRatio(const QSize& pixelRatio);
	bool horizontalFlip() const;
	void setHorizontalFlip(const bool verticalFlip);
	bool verticalFlip() const;
	void setVerticalFlip(const bool verticalFlip);
	SampleGrabberCallback* sampleGrabberCallback() const;
	void setSampleGrabberCallback(SampleGrabberCallback*);
public:
	bool isOpened() const;
	bool isRunning() const;
	virtual QImage grabImage() const = 0;
	virtual void open();
	virtual void close();
	virtual void start();
	virtual void stop();
	virtual void restart();
signals:
	void imageUpdated(const QImage&);
public slots:
	virtual void moveTo(const QPointF&);

protected:
	Capturer(CapturerPrivate &dd, QObject *parent = 0);
	QScopedPointer<CapturerPrivate> d_ptr;
private:		
	Q_DECLARE_PRIVATE(Capturer);
	Q_DISABLE_COPY(Capturer);	
};

class VirtualCapturerPrivate;
class VirtualCapturer : public Capturer
{
	Q_OBJECT
public:
	VirtualCapturer(const uint index, const QString& fileName, QObject* parent);
	~VirtualCapturer();
public:
	QString fileName() const;
	void setFileName(const QString&);
public:
	virtual QImage grabImage() const;
public:
	virtual void moveTo(const QPointF&);
private:		
	Q_DECLARE_PRIVATE(VirtualCapturer);
};

#endif // CAPTURER_H
